Function.prototype.curry = function (...args) {
  const allArgs = []
  const fn = this

  const curry = (...args) => {
    allArgs.push(...args)
    return (fn.length === allArgs.length)
      ? fn.call(this, ...allArgs)
      : curry
  }

  return curry(...args)
}

function add(a, b, c) {
  return a + b + c
}

console.log(
  add(1, 2, 3)
)
console.log(
  add.curry(1)(2, 3)
)
